<!DOCTYPE HTML>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title>AUI快速完成布局</title>
    <link rel="stylesheet" type="text/css" href="../css/aui.css" />

</head>

<body>
  <div style="text-align:center;margin:0.625rem;display:none;background:#fff;padding:1.25rem;" id="default-1">
      <img src="./img/muyou.png" style="display:inline;">
      <p><span style="font-size:1.25rem;">亲,</span>&nbsp;&nbsp;&nbsp;&nbsp;您当前木有消息</p>
  </div>
<div id="list">

</div>
</body>

<script type="text/template" id="template">
    {{~it:value:index}}
    <div class="aui-content" style="background:#fff;margin-top:5px;padding:5px 0;">
        <div class="aui-row">
            <div class="aui-col-xs-12" style="padding:5px 20px;text-align:left;">
                <span style="color:#ff4285">时间:</span>{{= userDate(value.inputtime)}}
            </div>

            <div class="aui-col-xs-12" style="padding:5px 20px;text-align:left;">
                <span style="color:#ff4285">内容：</span>{{= value.content}}
            </div>
        </div>

    </div>
    {{~}}
</script>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="./conf/config.js"></script>
<script type="text/javascript" src="./js/common.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/doT.min.js"></script>
<script type="text/javascript">
    apiready = function() {

        fnGetData(); //获取用户信息分配到模板
        //initRefresh() ;//下拉

    };
    function userDate(uData){
      var myDate = new Date(uData*1000);
      var year = myDate.getFullYear();
      var month = myDate.getMonth() + 1;
      var day = myDate.getDate();
      var hours = myDate.getHours();
      var minutes = myDate.getMinutes();
      return year + '-' + month + '-' + day+" "+hours+":"+minutes;
    }
    function  fnGetData() {
        var userInfo = $api.getStorage("userInfo");
        var userid = userInfo.userid;
        var random = userInfo.random;
        api.ajax({
            url: SITE_URL+'index.php?m=api&c=appnew&a=getmessage',
            method: 'get',
            data: {
                values: {
                    "userid": userid,
                    "random": random,
                    "type": 1,
                }
            }
        }, function(ret, err) {
        //alert(JSON.stringify(ret));
            fnUpdata(ret);


        });
    };
    //把数据分配到模板上面

    function  fnUpdata(ret) {
      if(ret.count==0){
        $("#default-1").show();return false;
      }
        //数组分配到模板；
        var list = $api.byId('list'); //获取节点
        //var str={"array":["banana","apple","orange"]};
        // 1. 编译模板函数
        var tempFn = doT.template($api.byId('template').innerHTML); //找到模板多次使用
        // 2. 多次使用模板函数
        var resultText = tempFn(ret.lists);

        $api.html(list, resultText);

    }


    function initEventListenner() {

        api.addEventListener({
            name: 'keyback'
        }, function(ret, err) {
            api.closeWin();
        });
    };



</script>

</html>
